package com.XinYun.Library.modules.admin.borrowMsg.dao;

import cn.hutool.core.util.StrUtil;
import com.XinYun.Library.modules.admin.borrowMsg.entity.BorrowMsg;
import com.XinYun.Library.modules.admin.common.BasicDao;
import com.XinYun.Library.modules.admin.common.SqlMapper;
import java.util.List;

public class BorrowMsgDao extends BasicDao {

    /**
     * 搭配SqlMapper使用，
     * @param sqlMethod
     * @param pagesize
     * @param pageindex
     * @param isSearch 可填null或着空字符串
     * @return
     */
    public List<BorrowMsg> sqlPageFactory(SqlMapper sqlMethod, int pagesize, int pageindex, String isSearch){
        String sql = sqlMethod.getSql();
        /*if(isSearch == null || "".equals(isSearch))*///这里我直接用工具类了，基本写法为左
        if (!StrUtil.isEmpty(isSearch)){
            sql += isSearch;
        }
        return pageBeanSelect(sql,pagesize,pageindex,BorrowMsg.class);
    }

    public Long getDataNum(SqlMapper sqlMethod, String isSearch){
        String sql = sqlMethod.getSql();
        if (!StrUtil.isEmpty(isSearch)){
            sql += isSearch;
        }
        List<Long> num = dqlForScalar(sql,Long.class);
        return Long.valueOf(num.get(0));
    }
}
